<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>百度离线版2.0DEMO</title>
<script type="text/javascript"
	src="http://localhost:8081/baidumap.server/js/apiv2.0.js?v=2"
	charset="utf-8"></script>

<script type="text/javascript"
	src="http://localhost:8081/baidumap.server/js/baidu.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery-2.2.4.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="http://localhost:8081/baidumap.server/css/bmap.css" />
</head>
<body style="margin: 0px;overflow: hidden;">
	<select onchange="selectControl(this);">
		<option value="createDistance">测距</option>
		<option value="createZoomOut">放大</option>
		<option value="createDrawing">点线面</option>
		<option value=closeControl>拖动</option>
	</select>
	<div style="width:100%;border:1px solid gray" id="container"></div>
</body>
</html>
<script type="text/javascript">
	$("#container").height($(document).height()-100);
	$baidu.install([ 'draw', 'distance', 'zoom', 'window' ]);
	

	var bm = $baidu.createMap(
		{
			id : "container"
		}
	);



	var map = bm.map;
	var point = new BMap.Point(111.404, 40.915); // 创建点坐标
	map.centerAndZoom(point, 5); // 初始化地图,设置中心点坐标和地图级别。

	//map.addControl(new BMap.MapTypeControl());
	map.addControl(new BMap.NavigationControl());
	map.enableScrollWheelZoom(); // 启用滚轮放大缩小。
	map.enableKeyboard(); // 启用键盘操作。  
	//map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的



	var marker = new BMap.Marker(point);
	map.addOverlay(marker);

	var polyline = new BMap.Polyline([
		new BMap.Point(111.404, 40.915),
		new BMap.Point(112.404, 42.915),
		new BMap.Point(113.404, 39.915),
		new BMap.Point(114.404, 42.915),
		new BMap.Point(115.404, 39.915),
		new BMap.Point(116.404, 42.915)
	], {
		strokeColor : "blue",
		strokeWeight : 2,
		strokeOpacity : 0.5
	});

	polyline.addEventListener("mouseover", function(e) {
		try {
			$baidu.openWindow(bm, {
				content : "aaa",
				title : "bbb",
				width : 320,
			}, e);
		} catch (e) {
			console.log(e);
		}
	});

	map.addOverlay(polyline);

	var polyline1 = new BMap.Polyline([
		new BMap.Point(116.399, 39.910),
		new BMap.Point(116.405, 39.920),
		new BMap.Point(116.423493, 39.907445)
	], {
		strokeColor : "blue",
		strokeWeight : 2,
		strokeOpacity : 0.5
	}); //创建折线
	map.addOverlay(polyline1); //增加折线

	var polygon = new BMap.Polygon([
		new BMap.Point(116.387112, 39.920977),
		new BMap.Point(116.385243, 39.913063),
		new BMap.Point(116.394226, 39.917988),
		new BMap.Point(116.401772, 39.921364),
		new BMap.Point(116.41248, 39.927893)
	], {
		strokeColor : "blue",
		strokeWeight : 2,
		strokeOpacity : 0.5
	}); //创建多边形
	map.addOverlay(polygon); //增加多边形

	polyline1.enableEditing();polygon.enableEditing();
	
	function selectControl(c){
		$baidu[$(c).val()](bm);
	}
	
</script>
